<?php

require_once 'phpmoko/ui/Widget.php';

class DecoratorPanel extends Widget
{
	private $widget = null;

	function __construct()
	{
		parent::__construct();
	}

	function setWidget($widget)
	{
		if ($widget instanceof Widget)
			$this->widget = $widget;
		else
			$this->widget = new HTML($widget);
	}

	function toString()
	{
		$str = '<table class="pmk-DecoratorPanel" cellpadding="0" cellspacing="0"';
		if ($this->id != null)
			$str .= ' id="'.$this->id.'"';

		if ($this->getWidth() != null)
			$str .= ' width="'.$this->getWidth().'"';

		$str .= '>';
			
			$str .= '<tr class="top">';
				$str .= '<td class="topLeft">';
					$str .= '<div class="topLeftInner"></div>';
				$str .= '</td>';
				$str .= '<td class="topCenter">';
					$str .= '<div class="topCenterInner"></div>';
				$str .= '</td>';
				$str .= '<td class="topRight">';
					$str .= '<div class="topRightInner"></div>';
				$str .= '</td>';
			$str .= '</tr>';
			$str .= '<tr class="middle">';
				$str .= '<td class="middleLeft">';
					$str .= '<div class="middleLeftInner"></div>';
				$str .= '</td>';
				$str .= '<td class="middleCenter">';
					$str .= '<div class="middleCenterInner">';
					$str .= $this->widget->toString();
					$str .= '</div>';
				$str .= '</td>';
				$str .= '<td class="middleRight">';
					$str .= '<div class="middleRightInner"></div>';
				$str .= '</td>';
			$str .= '</tr>';
			$str .= '<tr class="bottom">';
				$str .= '<td class="bottomLeft">';
					$str .= '<div class="bottomLeftInner"></div>';
				$str .= '</td>';
				$str .= '<td class="bottomCenter">';
					$str .= '<div class="bottomCenterInner"></div>';
				$str .= '</td>';
				$str .= '<td class="bottomRight">';
					$str .= '<div class="bottomRightInner"></div>';
				$str .= '</td>';
			$str .= '</tr>';
		$str .= '</table>';

		return $str;
	}
}
?>